package org.example.shop.user.controller;

import org.example.shop.entity.User;
import org.example.shop.user.service.UserService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
public class UserController {

    @Resource
    private UserService userService;

    @GetMapping("user/{uid}")
    public ResponseEntity<User> find(@PathVariable Integer uid) {
        return ResponseEntity.ok(userService.findByUid(uid));
    }

    @PostMapping("user/add")
    public ResponseEntity<User> add(@RequestBody User user) {
        return ResponseEntity.ok(userService.save(user));
    }
}
